home *** CD-ROM | disk | FTP | other *** search
- #include "PostPre.h"
- #include "Global.h"
- #include "PostWin.h"
-
- struct RDArgs my_rdargs;
-
- /*
- * The strings in this program
- */
- static char *strings[]=
- {
- "Window already open", /* STR_ID_WINDOW_OPEN */
- "Window already closed", /* STR_ID_WINDOW_CLOSE */
- "Window is not open", /* STR_ID_WINDOW_NONE */
- "ps-file is not conforming!", /* STR_ID_PSFILE */
- "interpreter is not paused", /* STR_ID_PAUSED */
- "Argument error to command %s", /* STR_ID_ARGUMENT */
- "you are already on this page", /* STR_ID_PAGE_OK */
- "you are already on the first page", /* STR_ID_PAGE_FIRST */
- "page-number too high, gone to last page", /* STR_ID_PAGE_HIGH */
- "page-number too low, gone to first page", /* STR_ID_PAGE_LOW */
- "interpreter is not running", /* STR_ID_RUNNING */
- "no command or command string too long", /* STR_ID_STRING */
- "can't quit or clear during startup or interactive", /* STR_ID_QUIT */
- "the current displaymode does not support enough colors!", /* OPT_COLORS */
- "error during initiation", /* OPT_CREATE */
- "Can't obtain needed Pens!", /* OPT_PENS */
- };
-
- static char *cBuf, *nextchar, *error=NULL, *result=NULL, empty[]="";
- static long errlevel=0;
-
-
- void ProcessARexx(void)
- {
- char errorstr[256], helpstr[256], arg0[256], varname[30], *dummy;
- int next_page_number, err_id;
- int left = 0, top = 0, width = 0, height = 0;
-
- errlevel = 0;
- error = NULL;
- result = NULL;
-
- if(strlen(ARG0(rmsg)) == 0 || strlen(ARG0(rmsg)) > 255)
- {
- error=strings[STR_ID_STRING];
- errlevel=10;
- SetARexxLastError(RexxStuff,rmsg,error);
- ReplyARexxMsg(RexxStuff,rmsg,result,errlevel);
- rmsg = NULL;
- return;
- }
- else
- {
- strcpy(arg0, ARG0(rmsg));
- }
-
- cBuf = strtok(arg0, " ,");
- nextchar = strtok(NULL, "");
- if(nextchar == NULL) nextchar = empty;
- if (!stricmp("OPENWINDOW",cBuf))
- {
- if (OutputWnd)
- {
- error=strings[STR_ID_WINDOW_OPEN];
- errlevel=5;
- }
- else
- {
- openwindow();
- do_blit();
- }
- }
- else if (!stricmp("CLOSEWINDOW",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_CLOSE];
- errlevel=5;
- }
- else
- {
- closewindow();
- }
- }
- else if (!stricmp("WINDOWTOFRONT",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else
- {
- WindowToFront(OutputWnd);
- }
- }
- else if (!stricmp("WINDOWTOBACK",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else
- {
- WindowToBack(OutputWnd);
- }
- }
- else if (!stricmp("ACTIVATEWINDOW",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else
- {
- ActivateWindow(OutputWnd);
- }
- }
- else if (!stricmp("SCREENTOFRONT",cBuf))
- {
- ScreenToFront(Options.Screen.custscreen ? custscreen : pubscrcontext.pubscreen);
- }
- else if (!stricmp("SCREENTOBACK",cBuf))
- {
- ScreenToBack(Options.Screen.custscreen ? custscreen : pubscrcontext.pubscreen);
- }
- else if (!stricmp("ZIPWINDOW",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else
- {
- blit_to_window = FALSE;
- ZipWindow(OutputWnd);
- blit_to_window = TRUE;
- }
- }
- else if (!stricmp("CHANGEWINDOWBOX",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else if(*nextchar && (sscanf(nextchar, "%d %d %d %d", &left, &top, &width, &height) == 4))
- {
- blit_to_window = FALSE;
- ChangeWindowBox(OutputWnd, left, top, width, height);
- blit_to_window = TRUE;
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "CHANGEWINDOWBOX");
- error=errorstr;
- }
- }
- else if (!stricmp("LEFT",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else if(*nextchar && sscanf(nextchar, "%d", &left))
- {
- do_gadgets(GAD_LEFT, left);
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "LEFT");
- error=errorstr;
- }
- }
- else if (!stricmp("RIGHT",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else if(*nextchar && sscanf(nextchar, "%d", &left))
- {
- do_gadgets(GAD_RIGHT, left);
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "RIGHT");
- error=errorstr;
- }
- }
- else if (!stricmp("UP",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else if(*nextchar && sscanf(nextchar, "%d", &left))
- {
- do_gadgets(GAD_UP, left);
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "UP");
- error=errorstr;
- }
- }
- else if (!stricmp("DOWN",cBuf))
- {
- if (OutputWnd == NULL)
- {
- error=strings[STR_ID_WINDOW_NONE];
- errlevel=5;
- }
- else if(*nextchar && sscanf(nextchar, "%d", &left))
- {
- do_gadgets(GAD_DOWN, left);
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "DOWN");
- error=errorstr;
- }
- }
- else if (!stricmp("CLEAR",cBuf))
- {
- if(interactive || startup)
- {
- errlevel = 5;
- error = strings[STR_ID_QUIT];
- }
- else MenuClear();
- }
- else if (!stricmp("OKMSG",cBuf))
- {
- okmsg(nextchar);
- }
- else if (!stricmp("OPEN",cBuf) || !stricmp("LOADFONT",cBuf))
- {
- strcpy(Options.lastfile, nextchar);
- sendfile(PSACTFILE);
- }
- else if (!stricmp("RUN",cBuf))
- {
- strcpy(Options.lastfile, nextchar);
- sendfile(PSACTRUN);
- }
- else if (!stricmp("NEXTPAGE",cBuf))
- {
- if (err_id = nextpage())
- {
- error=strings[err_id];
- errlevel=5;
- }
- }
- else if (!stricmp("PREVIOUSPAGE",cBuf))
- {
- if (err_id = previouspage())
- {
- error=strings[err_id];
- errlevel=5;
- }
- }
- else if (!stricmp("GOTOPAGE",cBuf))
- {
- if(*nextchar && sscanf(nextchar, "%d", &next_page_number))
- {
- if(running && paused)
- {
- if(number_of_pages)
- {
- if(next_page_number < 1)
- {
- next_page_number = 1;
- errlevel = 5;
- error = strings[STR_ID_PAGE_LOW];
- }
- else if (next_page_number > number_of_pages)
- {
- next_page_number = number_of_pages;
- errlevel = 5;
- error = strings[STR_ID_PAGE_HIGH];
- }
- if (err_id = gotopage(next_page_number))
- {
- errlevel = 5;
- error = strings[err_id];
- }
- }
- else
- {
- errlevel = 5;
- error = strings[STR_ID_PSFILE];
- }
- }
- else
- {
- errlevel = 5;
- error = strings[STR_ID_PAUSED];
- }
- }
- else
- {
- errlevel = 10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "GOTOPAGE");
- error=errorstr;
- }
- }
- else if (!stricmp("QUIT",cBuf))
- {
- if(interactive || startup)
- {
- errlevel = 5;
- error = strings[STR_ID_QUIT];
- }
- else
- {
- if (error)
- {
- SetARexxLastError(RexxStuff,rmsg,error);
- }
- ReplyARexxMsg(RexxStuff,rmsg,result,errlevel);
- rmsg = NULL;
- errorende();
- exit(0);
- }
- }
- else if (!stricmp("GETSTATUS",cBuf))
- {
- if(interactive) dummy = titleinter;
- else if(arexx) dummy = titlearexx;
- else if(paused) dummy = titlepaused;
- else if(startup) dummy = titlestart;
- else if(running) dummy = titlerunning;
- else dummy = titlewait;
- sprintf(varname, "%s.STATUS", AREXXPORTNAME);
- SetARexxVariable(RexxStuff, rmsg, varname, dummy);
- sprintf(varname, "%s.ERROR", AREXXPORTNAME);
- if(errstr) SetARexxVariable(RexxStuff, rmsg, varname, errstr);
- else SetARexxVariable(RexxStuff, rmsg, varname, "No Error");
- sprintf(helpstr, "%d", retcode);
- sprintf(varname, "%s.ERRORNUM", AREXXPORTNAME);
- SetARexxVariable(RexxStuff, rmsg, varname, helpstr);
- }
- else if (!stricmp("INTERRUPT",cBuf))
- {
- if(running && !paused) PSsignalint(arec, 1);
- else
- {
- error=strings[STR_ID_RUNNING];
- errlevel=5;
- }
- }
- else if (!stricmp("KILL",cBuf))
- {
- if(running && !paused) PSsignalint(arec, 2);
- else
- {
- error=strings[STR_ID_RUNNING];
- errlevel=5;
- }
- }
- else if (!stricmp("SETOPTS",cBuf))
- {
- if(*nextchar)
- {
- struct Options opts_bak;
-
- strcpy(helpstr, nextchar);
- strcat(helpstr, "\n");
- my_rdargs.RDA_Source.CS_Buffer = helpstr;
- my_rdargs.RDA_Source.CS_Length = strlen(helpstr);
- my_rdargs.RDA_Source.CS_CurChr = 0;
- my_rdargs.RDA_DAList = 0;
- my_rdargs.RDA_Buffer = NULL;
- my_rdargs.RDA_BufSiz = 0;
- my_rdargs.RDA_ExtHelp = NULL;
- my_rdargs.RDA_Flags = 0;
- copy_options(&opts_bak, &Options);
- argwindow = FALSE;
- if(parse(1, &my_rdargs))
- {
- errlevel = 5;
- error = undobuff;
- }
- else
- {
- copy_options(&TempOptions, &Options);
- copy_options(&Options, &opts_bak);
- if(errlevel = do_opts())
- {
- copy_options(&Options, &opts_bak);
- if(errlevel == OPT_CREATE || errlevel == OPT_PENS)
- {
- saveterminate();
- sendmenu(PSACTCREATE, 0, 0, 0, NULL, NULL);
- Wait(1L << create_signal);
- if(createerror)
- {
- errlevel = 20;
- SetARexxLastError(RexxStuff,rmsg,"can't activate old prefs");
- ReplyARexxMsg(RexxStuff,rmsg,result,errlevel);
- rmsg = NULL;
- errorende();
- exit(0);
- }
- if(errlevel == OPT_PENS)
- {
- openwindow();
- do_blit();
- }
- runstartupfiles();
- }
- error = strings[errlevel];
- errlevel = 10;
- }
- }
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "SETOPTS");
- error=errorstr;
- }
- }
- else if (!stricmp("CUSTOMSCREEN",cBuf))
- {
- do_screen();
- }
- else if (!stricmp("PUBSCREEN",cBuf))
- {
- if(*nextchar)
- {
- if(strlen(nextchar) > MAXPUBSCREENNAME)
- {
- okmsg("pubscrn to long");
- }
- else
- {
- strcpy(newpubscreenname, nextchar);
- if(errlevel = do_pubscreen())
- {
- error = strings[errlevel];
- errlevel = 10;
- }
- }
-
- }
- else
- {
- errlevel=10;
- sprintf(errorstr, strings[STR_ID_ARGUMENT], "PUBSCREEN");
- error=errorstr;
- }
- }
- else
- {
- sendmenu(PSACTAREXX, 0, 0, 0, NULL, ARG0(rmsg));
- return;
- }
-
- if (error)
- {
- SetARexxLastError(RexxStuff,rmsg,error);
- }
- if(rmsg)
- {
- ReplyARexxMsg(RexxStuff,rmsg,result,errlevel);
- rmsg = NULL;
- }
- return;
- }
-